Cookiebot easy install tool with Cloudflare Workers
Classmethod proudly provides a service known as Cookiebot, an indispensable tool enabling the incorporation of cookie consent banners across various websites.
We have further elevated our service offering by developing a user-friendly tool which facilitates the installation of Cookiebot through the utilization of Cloudflare Workers.
So what is it
Details of our newly developed tool can be accessed via the following link: https://cookiebot.classmethod.cf/
The tool is straightforward and easy to use
- Begin by entering your Cookiebot Domain Group ID, which is accessible from the Cookiebot admin screen.
- For Google Tag Manager users, you are required to input your GTM ID.
- Following these steps, the tool will generate a code at the bottom of the screen, which should be pasted into the Cloudflare Workers that you've previously created.
- Subsequently, deploy the Cloudflare Workers within your preferred root and domain.
By following these steps, the GTM-adapted Cookiebot code will be integrated into the HEAD of each web page, allowing it to operate on virtually any site.
In the event that you are using a CMS or site generator, or if for some reason you're unable to modify the HEAD, Cloudflare Workers will automatically install the necessary tags to deploy Cookiebot.
So why we developed it
About Cookiebot
Cookiebot is a Consent Management Platform (CMP) that displays a 'You are using cookies' notification upon a user's first visit to a website. Embedding a simple script allows Cookiebot to manage the delivery and blocking of other scripts based on user consent, list the cookies used, and handle opt-out preferences.
Classmethod has entered into a partnership agreement with Cookiebot, providing implementation support and offering resales in Japanese. This collaboration has led to a steady increase in contracts.
Major issue in Cookiebot implementation
While implementing Cookiebot poses less of a burden compared to competitor services, careful attention must be paid to script embedding locations, and adjustments must be made to the installation procedure depending on the CMS operating in the background.
Our desire to simplify and optimize this process led to the creation of this tool utilizing Cloudflare Workers.
Further information about the tool
The tool serves as a service that generates scripts to operate on Cloudflare Workers.
About Cloudflare
Cloudflare, as described on its introduction page;
Cloudflare is a global network designed to make everything you connect to the Internet secure, private, fast, and reliable.
Moreover, Cloudflare Workers is a serverless service that enables the deployment and execution of code on the edge of Cloudflare's CDN, facilitating the swift deployment of JavaScript running at sub-millisecond execution speeds.
What Does it Do?
Cloudflare Workers act as intermediaries between the site visitor and the origin site, incorporating Cookiebot scripts into the origin and returning content to the visitor.
The script is embedded into the origin HEAD using HTMLRewriter, a built-in selector-based HTML parser in the Workers runtime.
HTMLRewriter permits the modification of HTML tags, addition of attributes, text replacement, and element deletion on the edge. It offers a comprehensive set of methods to control where in the HEAD the content rewrite occurs.
before()
: Insert before a certain HTML elementafter()
: Insert after a certain HTML elementprepend()
: Insert just after a certain HTML beginning tagappend()
: Insert just before a certain HTML ending tag
The positioning of other scripts and the manner in which GTM snippets are written influence the functionality of Cookiebot. As a result, Workers manages the order of these scripts.
Requirements
In order to utilize this tool, the following are required:
- A Cookiebot account (register here)
- A Cloudflare account
You can start using Cloudflare Workers with Free account.
In Closing
During the development of this tool, Fruition served as a valuable reference. Fruition is an open-source Notion site wrapper, which can be found here:
Fruition: Free, Open Source Toolkit for Building Websites with Notion.
We also maintain a sibling tool called Worknot, which we develop based on the above. The following link directs to the Worknot tool:
https://github.com/classmethod/worknot
For further inquiries or if you wish to utilize any of the above-mentioned tools, Cookiebot, or Cloudflare, please do not hesitate to contact us.